<?php

namespace App\Http\Requests\Api\User;

use App\Http\Requests\Api\BaseRequest;

class SendMsgRequest extends BaseRequest
{

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'tel'=>[
                'required',
                'regex:/^1[3456789]\d{9}$/u',
                function($attribute,$value,$fail){
                    if($value != auth('api')->user()->tel){
                        return $fail('手机号非本账号绑定号码，请重新输入');
                    }
                },
            ]
        ];
    }

   public function attributes()
   {
       return [
         'tel'=>'手机号码'
       ];
   }
}
